import { createRouter, createWebHistory } from 'vue-router'
// createRouter方法,用户创建路由器实例,用于管理多个路由
export default createRouter({
    // 设置路由的模式
    history: createWebHistory(),
    // 管理路由
    routes: [
        {
            path: '/home',
            name: 'Home',
            component: () => import('@/pages/home/index.vue'),
            meta: {
                title: '首页'
            }
        },
        {
            path: '/hospital',
            name: 'Hospital',
            component: () => import('@/pages/hospital/index.vue'),
            children: [
                {
                    path: 'register',
                    name: 'Register',
                    component: () => import('@/pages/hospital/register/index.vue'),
                    meta: {
                        title: '预约挂号'
                    }
                },
                {
                    path: 'detail',
                    name: 'Detail',
                    component: () => import('@/pages/hospital/detail/index.vue'),
                    meta: {
                        title: '医院详情'
                    }
                },
                {
                    path: 'notice',
                    name: 'Notice',
                    component: () => import('@/pages/hospital/notice/index.vue'),
                    meta: {
                        title: '预约须知'
                    }
                },
                {
                    path: 'close',
                    name: 'Close',
                    component: () => import('@/pages/hospital/close/index.vue'),
                    meta: {
                        title: '停诊信息'
                    }
                },
                {
                    path: 'search',
                    name: 'Search',
                    component: () => import('@/pages/hospital/search/index.vue'),
                    meta: {
                        title: '信息查询'
                    }
                },
                {
                    path: 'register_step1',
                    name: 'Register_step1',
                    component: () => import('@/pages/hospital/register/register_step1.vue'),
                    meta: {
                        title: '预约第一步'
                    }
                },
                {
                    path: 'register_step2',
                    name: 'Register_step2',
                    component: () => import('@/pages/hospital/register/register_step2.vue'),
                    meta: {
                        title: '预约第二步'
                    }
                }
            ]
        },
        {
            path: '/wxlogin',
            name: 'Wxlogin',
            component: () => import('@/pages/wxlogin/index.vue'),
            meta: {
                title: '微信登录'
            }
        },
        {
            path: '/user',
            name: 'User',
            component: () => import('@/pages/user/index.vue'),
            children: [
                {
                    path: 'certification',
                    name: 'Certification',
                    component: () => import('@/pages/user/certification/index.vue'),
                    meta: {
                        title: '实名认证'
                    }
                },
                {
                    path: 'feedback',
                    name: 'Feedback',
                    component: () => import('@/pages/user/feedback/index.vue'),
                    meta: {
                        title: '意见反馈'
                    }
                },
                {
                    path: 'order',
                    name: 'Order',
                    component: () => import('@/pages/user/order/index.vue'),
                    meta: {
                        title: '挂号订单'
                    }
                },
                {
                    path: 'patient',
                    name: 'Patient',
                    component: () => import('@/pages/user/patient/index.vue'),
                    meta: {
                        title: '就诊人管理'
                    }
                },
                {
                    path: 'profile',
                    name: 'Profile',
                    component: () => import('@/pages/user/profile/index.vue'),
                    meta: {
                        title: '账号信息'
                    }
                },
            ]
        },
        {
            path: '/',
            redirect: '/home'
        },
        {
            path: '/:pathMatch(.*)*',
            name: '404',
            component: () => import('@/pages/404/404.vue'),
            meta: {
                title: '404'
            }
        },
    ],
    // 滚动行为:每一次切换路由的时候,滚动到最上面
    scrollBehavior() {
        return {
            left: 0,
            top: 0
        }
    }
})